import Vue from 'vue'
const loadMore = Vue.directive('loadMore', {
  bind(el, binding) {
    const selectWrap = el.querySelector('.el-table__body-wrapper');
    console.log(selectWrap)
    selectWrap.addEventListener('scroll', function () {
      window.sessionStorage.setItem('loadTop'+binding.value[1], this.scrollTop);
      window.sessionStorage.setItem('loadLeft'+binding.value[1], this.scrollLeft);
    });
  },
  componentUpdated(el,binding) {
    const selectWrap = el.querySelector('.el-table__body-wrapper');
    let l = window.sessionStorage.getItem('loadLeft'+binding.value[1]) || 0;
    let t = window.sessionStorage.getItem('loadTop'+binding.value[1]) || 0;
    setTimeout(() => {
      selectWrap.scrollTo(l, t);
    }, 200);
  },
  update() {
  }
});

export default loadMore
